package model;

/**
 * Super class for all cards that forces money from the player. The draw method is the main 
 * method which determines whether the player has enough money or not. 
 * @author Group 20
 */
public abstract class Expense extends Card
{
	protected int pay;

	public Expense(String description, int pay) {
		super(description);
		this.pay = pay;
	}
	
	/**
	 * Determines if player has enough money to pay for the expense that the card forces on him/her. If so, then do it.
	 */
	@Override
	public boolean draw(Player player) {
		int toPay = calculateExpense();
		payment = -toPay;
		if(player.getBalance() >= toPay)
		{
			player.withdraw(toPay);
			return true;
		}
		else
			return false;
	}
	
	public abstract int calculateExpense();

	@Override
	public String toString() {
		return ", pay=" + pay + ", description=" + description + super.toString() +"]";
	}
}
